package singleton.myExam;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Iterator;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import decorator.files.FileTest;

public class Config {
	private static Config unique = new Config();
	private String key = null;
	public static String aaa = "";
	private Config(){}
	static {
		aaa = "aaa";
	}
	public static String getInstance(String key){		
		return unique.getConf(key);
	}
	private String getConf(String confKey){
		aaa = confKey;
		JSONParser parser = new JSONParser();
		String value = null;
		try{
			Object obj = parser.parse(new FileReader(Config.class.getResource("").getPath()+"conf.json"));
			JSONObject jsonObject = (JSONObject) obj;
			 
			if(confKey.equals("jdk_version") ){
				value = (String) jsonObject.get("jdk_version");
			}else if(confKey.equals("use_was")){
				value = (String) jsonObject.get("use_was");
			}else {
				value = "key가 없음";
			}
	 			
			
			
		}catch(Exception e) {
			e.getStackTrace();
		}
		return value;		
	}
}
